package com.hy.admin.security.service.business;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import com.hy.admin.domain.shared.security.HyUserDetails;
import com.hy.admin.entity.MemberEntity;

public class SecurityCurrentUserLoader {

	public MemberEntity load() {
		final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		MemberEntity memberEntity = null;
		if (authentication.getPrincipal() instanceof HyUserDetails) {
			HyUserDetails userDetails=(HyUserDetails)authentication.getPrincipal();
			memberEntity=userDetails.getMemberEntity();
		}
		return memberEntity;
        
	}
	
}
